import socket


def main():
    # 建立tcp socket
    tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    # 连接服务器
    tcp_socket.connect(("192.168.159.1", 8088))

    # 发送数据
    data_str = input("请输入要发送的数据:")
    tcp_socket.send(data_str.encode("gbk"))

    # 关闭连接
    tcp_socket.close()


if __name__ == '__main__':
    main()
